package architect.design.patterns.behavior.interpreter;

/**
 * 加法
 *
 * @author guanxin
 * @date 2018/5/6 13:44
 */

public class PlusExpression extends Expression {

    private Expression leftExpression;
    private Expression rightExpression;

    public PlusExpression(
            Expression leftExpression,
            Expression rightExpression) {
        this.leftExpression = leftExpression;
        this.rightExpression = rightExpression;
    }

    @Override
    public int interpret() {
        return leftExpression.interpret() + rightExpression.interpret();
    }

    @Override
    public String toString() {
        return "+";
    }
}
